package tech.aistar.corejava.day06.extend;

/**
 * Created by 李雨昂 on 2019/7/22.
 */
public class Cat extends Animal {//使用extends来指明继承关系

    private double bud;

    public  Cat(){
        /*surper()
        * 出现在构造中 - 默认是省略的
        * 显示的去调用父类的空参构造
        * 必须出现在首行
        * */
        super();
        System.out.println("Cat()...空参构造被调用了!");
    }
    public Cat(String name,double bud){
        super(name);
        this.bud = bud;
    }

    public double getBud() {
        return bud;
    }

    public void setBud(double bud) {
        this.bud = bud;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Cat{");
        sb.append("bud=").append(bud);
        sb.append('}');
        //surper 成员 - 强制调用父类的成员
        return super.toString()+ sb.toString();
    }

    public void spark(){
        System.out.println("喵喵...");
    }

    public void catchMouse(){
        System.out.println("抓老鼠");
    }

}
